<template>
  <h1>猜数字练习</h1>
  <input type="text" placeholder="请输入数字" v-model="a">
  <button @click="guess()">猜一猜</button>
  <h4>小提示：{{tip}}</h4>
</template>

<script setup>
import {ref} from "vue";

const a = ref('');
const tip = ref('');
const num = parseInt(Math.random()*100+1);
console.log(num);
const guess = ()=>{
  if (a.value > num){
    tip.value = '猜大了';
  }else if (a.value < num){
    tip.value = '猜小了';
  }else {
    tip.value = '恭喜你，猜对了！';
  }
}
</script>

<style scoped>

</style>